import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import storage_get from '@dfeidao/atom-web/storage/get';

import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import P01 from './P01';

export default async function a001(fd: IFeidaoAiBrowserComponent, args: { tenantid: string }) {
	// 初始化
	const node = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-name="zj3"]');
	node.classList.remove('display-n');
	const productid = storage_get('productid');

	set(fd, 'productid', productid);

	const tenantid = args.tenantid;
	set(fd, 'tenantid', tenantid);
	const res1 = await nodejs<{ dataArray: Array<{ tenant_name: string; }> }>('tenant-inf/zj-000003/s001', { filter: { tenantid, productid } });
	if (res1.dataArray.length) {
		const tenant_name = res1.dataArray[0].tenant_name;
		set(fd, 'tenant_name', tenant_name);
		render(fd, res1.dataArray[0], P01, 'P01', 'inner');
	}
}
